import request from '@/utils/request'

/**
 * 获取通知公告列表
 * @param {Object} data: { page: 页码, pagesize: 每页条数 }
 * @return Promise
 */
export const getAnnounceListAPI = (params) => {
  return request({
    url: '/common/announce/',
    params
  })
}

/**
 * 根据title模糊查询公告
 * @param {Object} data: { page: 页码, pagesize: 每页条数, title: 标题 }
 * @return Promise
 */
export const queryAnnounceAPI = (params) => {
  return request({
    url: '/common/announce/query',
    params
  })
}

/**
 * 发布通知公告
 * @param {Object} data: { title: 标题, content: 内容, scope: 发布范围 }
 * @return Promise
 */
export const addAnnounceAPI = (data) => {
  return request({
    url: '/announce/',
    method: 'POST',
    data
  })
}

/**
 * 获取通知公告信息
 * @param id
 * @return Promise
 */
export const getAnnounceInfoAPI = (id) => {
  return request({
    url: `/common/announce/${id}`
  })
}

/**
 * 修改通知公告信息
 * @param {Object} data: { id, title: 标题, content: 内容, scope: 发布范围 }
 * @return Promise
 */
export const updateAnnounceAPI = (data) => {
  return request({
    url: '/announce/',
    method: 'PATCH',
    data
  })
}

/**
 * 删除通知公告
 * @param id
 * @return Promise
 */
export const deleteAnnounceAPI = (id) => {
  return request({
    url: `/announce/${id}`,
    method: 'DELETE'
  })
}
